package org.string;

import java.text.MessageFormat;
import java.util.Locale;

/**
 * @Author: xwg
 * @CreateDate: 2021/11/26
 */


public class StringTest {
    public static void main1(String[] args) {
//        String zhangsan = new String("zhangsan");
        String zhangsan = "ZhangSan是我";
        String s1 = zhangsan.toUpperCase();
        System.out.println(s1);
        String s = zhangsan.toLowerCase();
        System.out.println(s);
//        判定 包含子字符串 返回值boolean
        boolean zhang = zhangsan.contains("zhang");
        boolean san = zhangsan.contains("San");
        boolean abc = zhangsan.contains("abc");
//        判定开始结束
        boolean zh = zhangsan.startsWith("Zh");
        boolean zh1 = zhangsan.startsWith("Zb");
        boolean san是我 = zhangsan.endsWith("San是我");

//         3*1=3 3*2=6
        String a = "3*1=3";
        String b = "3*2=6";
        String c = "3*3=9";
        String joined = String.join("_", a, b, c);
        System.out.println(joined);
        String sss="3*1=3_3*2=6_3*3=9";
        String[] sr = sss.split("_");
        for (int i = 0; i < sr.length; i++) {
            System.out.println("分割后的值"+sr[i]);
        }

        String lisi = "lisi is very good";
        String subr = lisi.substring(3);
//        startwith endBefore [3,6)
        String subrt = lisi.substring(3, 6);

//        格式化
//        code   020306007
        Integer i=7 ;
//       "%04d" 代表四位数字 不足补0 digital
        String t1 = String.format("020306%03d", i);
        String t2 = String.format("020306%03d", 12);
        String t3 = String.format("020306%03d",11255);

        String t4 = String.format("%s%03d", "张三",i);
        String t5 = MessageFormat.format("{0}是{1}", "张三", "我弟弟");
        String t6 = MessageFormat.format("{0}是{1}", "李四", "我朋友");
        String t7 = MessageFormat.format("{1}是{0}", "王五", "我哥哥");

        System.out.println("");

    }

    public static void main(String[] args) {
//          abc=zhangsan=17
////        defg=wangwu=18
////        username age   Insert into Person (username ,age) values ('lisi',17)
        String t1 = "abc=zhangsan=17";
        String t2 = "defg=wangwu=18";
        String[] all = t2.split("=");
        String username = all[1];
        String age = all[2];
        String t = String.format("Insert into Person (username,age) values ( %s ,%s)", username,age);


//        3*2=6
        int a = 3;
        int b = 2;
        System.out.println(a+"*"+b+"="+a*b);
        System.out.println(String.format("%d*%d=%d", a,b,a*b));
        System.out.println(MessageFormat.format("{0}*{1}={2}",a,b,a*b));
        System.out.println();

    }


}
